<?php
namespace app\controller;

use app\service\LinkService;
use app\BaseController;
use app\service\GoodsService;
use app\service\CategoryService;
use think\App;
use think\facade\View;

class Index extends BaseController
{
    protected $categoryService;
    protected $goodsService;
    protected $linkService;

    /**
     * Category constructor.
     * @param App $app
     */
    public function __construct(App $app)
    {
        parent::__construct($app);
        $this->categoryService = app()->make(CategoryService::class);
        $this->goodsService = app()->make(GoodsService::class);
        $this->linkService = app()->make(LinkService::class);
    }

    public function index(): string
    {
        $data['recommends'] = $this->goodsService->queryListByNum(array(), 'commission_rate desc',10);
        $data['hotSales'] = $this->goodsService->queryListByNum(array(), 'month_sales desc',10);
        $data['bigCoupons'] = $this->goodsService->queryListByNum(array(), 'coupon_price desc',10);
        $data['friendLinks'] = $this->linkService->queryListByType();
        return View::fetch('index', $data);
    }
}
